const bodyParser = require('body-parser')
const userList = [{
	username: 'admin',
	password: 'admin',
	role: 'admin'
}, {
	username: 'common',
	password: 'common',
	role: 'common'
}]
module.exports = app => {
	app.use(bodyParser.json())
	app.post('/api/login', (req, res) => {
		const { username, password } = req.body;

		const result = userList.find(v => v.username === username && v.password === password)

		if(result) {
			res.send({
				code: 200,
				data: result
			})
		} else {
			res.send({
				code: 403,
			})
		}
	})
}